package cn.db101.kaoqinserver.controller;

import cn.db101.kaoqinserver.config.ApiResult;
import cn.db101.kaoqinserver.domain.Check;
import cn.db101.kaoqinserver.model.request.CheckParam;
import cn.db101.kaoqinserver.service.CheckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("v1/kaoqin/leave")
public class LeaveController {

    @Autowired
    private CheckService checkService;

    @PostMapping("list")
    public ApiResult<?> list() {

        return ApiResult.ofSuccess(checkService.leaveList());
    }

    @PostMapping("page")
    public ApiResult<?> page(@RequestBody CheckParam checkParam) {

        return ApiResult.ofSuccess(checkService.LeavePage(checkParam));
    }

    @PostMapping("audit")
    public ApiResult<?> audit(@RequestBody Check check) {

        checkService.changeAuditStatus(check);
        return ApiResult.ofSuccess(null);
    }

}
